package com.zx.centers.dataservice.mybatis.mapper.crawler;

import com.zx.centers.dataservice.mybatis.domain.crawler.CralwerWeather;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CralwerWeatherMapper {
    @Delete({
        "delete from cralwer_weather",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into cralwer_weather (id, weather_date, ",
        "weather_country, weather_city, ",
        "weather_status, create_time, ",
        "update_time)",
        "values (#{id,jdbcType=BIGINT}, #{weatherDate,jdbcType=DATE}, ",
        "#{weatherCountry,jdbcType=VARCHAR}, #{weatherCity,jdbcType=VARCHAR}, ",
        "#{weatherStatus,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{updateTime,jdbcType=TIMESTAMP})"
    })
    int insert(CralwerWeather record);

    @InsertProvider(type=CralwerWeatherSqlProvider.class, method="insertSelective")
    int insertSelective(CralwerWeather record);

    @Select({
        "select",
        "id, weather_date, weather_country, weather_city, weather_status, create_time, ",
        "update_time",
        "from cralwer_weather",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="weather_date", property="weatherDate", jdbcType=JdbcType.DATE),
        @Result(column="weather_country", property="weatherCountry", jdbcType=JdbcType.VARCHAR),
        @Result(column="weather_city", property="weatherCity", jdbcType=JdbcType.VARCHAR),
        @Result(column="weather_status", property="weatherStatus", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    CralwerWeather selectByPrimaryKey(Long id);

    @UpdateProvider(type=CralwerWeatherSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CralwerWeather record);

    @Update({
        "update cralwer_weather",
        "set weather_date = #{weatherDate,jdbcType=DATE},",
          "weather_country = #{weatherCountry,jdbcType=VARCHAR},",
          "weather_city = #{weatherCity,jdbcType=VARCHAR},",
          "weather_status = #{weatherStatus,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CralwerWeather record);
}